import java.io.*;
import java.net.*;
import java.util.*;
import com.aliasi.tokenizer.*;
import com.aliasi.symbol.*;
import com.aliasi.corpus.ObjectHandler;
import com.aliasi.util.ObjectToCounterMap;
import com.aliasi.util.Strings;
import com.aliasi.stats.Statistics;
import com.aliasi.classify.*; 
import com.aliasi.chunk.Chunk;
import com.aliasi.chunk.Chunker;
import com.aliasi.chunk.Chunking;
import com.aliasi.dict.DictionaryEntry;
import com.aliasi.dict.MapDictionary;
import com.aliasi.dict.TrieDictionary;
import com.aliasi.dict.Dictionary;
import com.aliasi.dict.ExactDictionaryChunker;
import com.aliasi.tokenizer.IndoEuropeanTokenizerFactory;
import edu.jhu.htm.core.*;

public class Geocoder {

        public class GeocoderResult {
          double latitude = 0.0;
          double longitude = 0.0;
          String geocode = "";
          double probability = 0.0;
	  Map<String,Double> nonZeroClassProbs = new HashMap<String,Double>(); 
        };

	private String modelPath = null;

	private ConditionalClassifier<CharSequence> model;

	private static final long serialVersionUID = -9186875057311859285L;

	public Geocoder( String path ) { 
		this.modelPath = path;
		this.model = null; // TODO: load model
	}

	public Geocoder( ConditionalClassifier<CharSequence> model ) { 
		this.modelPath = null;
		this.model = model;
	}

	public GeocoderResult processDocument ( String text ) { 
		// TODO : call the classifier and get the result
		GeocoderResult result = new GeocoderResult();
		if ( this.modelPath == null || this.modelPath.endsWith("model.classifier") ) {
			result.geocode = "EN34343";
			result.latitude = 0.0;
			result.longitude = 0.0;
			result.probability = 0.45;
		} else {
			result.geocode = "PT34343";
			result.latitude = 10.0;
			result.longitude = 10.0;
			result.probability = 0.15;
		}
		result.nonZeroClassProbs = new HashMap<String,Double>();
		result.nonZeroClassProbs.put("N34343",0.45);
		result.nonZeroClassProbs.put("N34341",0.1);
		return result;
	}

}
